<?php
session_start();
include "inc/implement.php";

$did = IntVal($_GET['did']);
if ($did > 0)
{
	$docs_s = "SELECT * FROM vzor_docs WHERE id = '".$did."' ";
	$docs_q = MySQL_Query ($docs_s);
	$docs_n = MySQL_Num_Rows ($docs_q);
	if ($docs_n == 1)
	{
		$docs = MySQL_Fetch_Array ($docs_q);
		Header ('Content-Description: File Transfer');
		Header ('Content-Type: application/octet-stream');
		Header ('Content-Disposition: attachment; filename='.$docs['nazov']);
		Header ('Content-Transfer-Encoding: binary');
		Header ('Expires: 0');
		Header ('Cache-Control: must-revalidate, post-check=0, pre-check=0');
		Header ('Pragma: public');
		Header ('Content-Length: ' . filesize(DOCS_ADDRESS.$docs['ftp']));
		ob_clean ();
		flush ();
		readfile (DOCS_ADDRESS.$docs['ftp']);
		exit ();
	}
}
?>